home *** CD-ROM | disk | FTP | other *** search
/ TeX 1995 July / TeX CD-ROM July 1995 (Disc 1)(Walnut Creek)(1995).ISO / macros / lollipop / address.tex < prev    next >
Text File  |  1993-01-28  |  5KB  |  171 lines

  1. % Address book macros
  2. % copyright 1993 Victor Eijkhout
  3. %
  4. % These macros are based on the Lollipop macro package,
  5. % copyright 1992/3 Victor Eijkhout
  6. %
  7. % Format this file twice to get external files right.
  8. %
  9.  
  10. % Some general options.
  11. % Please use another typeface if you have it!
  12. %
  13. \Distance:whitebefore=0pt \Distance:whiteafter=0pt
  14. \AlwaysIndent:no \FlushRight:no
  15. %\TypeFace:macHelvetica \PointSize:7 \Style:roman
  16. \TypeFace:ComputerSans \PointSize:8 \Style:roman
  17. \def\\{,\Spaces:1 }
  18.  
  19. % The page is four columns, no footers etc
  20. %
  21. \DefinePageGrid:ThePage width:page=6.5in height:page=5in
  22.  textband:start text white:10pt text white:10pt
  23.    text white:10pt text textband:stop Stop
  24.  
  25. % The main macro is the text block \Entity, representing one item
  26. % in the address book.
  27. %
  28. \DefineTextBlock:Entity HasTitle:short    
  29.  whitebefore:{6pt plus 6pt minus 3pt} whiteafter:whitebefore
  30.  line:start rule:v={height 7pt width7pt depth0pt} Spaces:2
  31.       Style:italic title line:stop Stop
  32.  
  33. % Data in an entity is formatted as a number of headings.
  34. % We declare all headings to be embedded, ie, they form a paragraph.
  35. % The 'nomarks' option is to prevent memory overflow.
  36. %
  37. \OptionsMacro:embed=embedded:yes nomarks
  38.  whitebefore:0pt whiteafter:0pt Stop
  39. \DefineHeading:phone HasTitle:short macro:embed 
  40.  literal:phone : Spaces:1.5 title , Spaces:2 Stop
  41. \DefineHeading:fax HasTitle:short macro:embed
  42.  literal:fax : Spaces:1.5 title , Spaces:2 Stop
  43. \DefineHeading:Address HasTitle:short macro:embed
  44.  title , Spaces:2 Stop
  45. \DefineHeading:Note HasTitle:short macro:embed 
  46.  ( title ) Spaces:2 Stop
  47.  
  48. % Here's an example of non-standard handling of the title:
  49. % email addresses are set in \tt, and can be broken differently
  50. %
  51. \def\breakemail{\hyphenchar\font=`. }
  52. \DefineHeading:email HasTitle:short macro:embed
  53.  begingroup tt breakemail title endgroup , Spaces:2 Stop
  54.  
  55. % This is invisible information; maybe later we'll do something
  56. % with it.
  57. \DefineHeading:Route HasTitle:short Stop
  58.  
  59. % Here is the first really cute application.
  60. % If a person is declared to be \At a certain company, then
  61. % that fact is written out to an external file, which can be loaded
  62. % later.
  63. %
  64. \DefineExternalFile:companies=ats
  65. \def\WorksAt{Works at: }
  66. \DefineHeading:At macro:embed 
  67.  HasTitle:short WorksAt title Spaces:2
  68.  external:companies title title:Entity external:stop Stop
  69. % When the 'companies' file gets loaded the title only gets
  70. % parsed by the macro \CompNam, and nothing else happens.
  71. % The title is split into company and person; #1 becomes the name
  72. % of a list to which #2 is added.
  73. %
  74. \def\CompNam#1\unhskip#2\unhskip{
  75.   \if\UndefinedCS{#1}\NewList:{#1} \fi
  76.   \AppendToList:#1={#2\unhskip, } }
  77. \DefineExternalItem:At file:companies 
  78.   expandafter CompNam title Stop
  79. % The company lists are later simply loaded; see below.
  80.  
  81. % Even more complicated: birthdays.
  82. % All birthdays are written to an external file.
  83. %
  84. \DefineExternalFile:births=brt
  85. \DefineHeading:birthday HasTitle:short macro:embed 
  86.   literal:Born : title Spaces:2 
  87.  external:births title title:Entity external:stop Stop
  88. % Later every month becomes something like an entity;
  89. % here is how we generate a token list for each month.
  90. %
  91. \def\month#1{\ifcase#1\or jan\or feb\or mar\or apr\or may\or jun\or
  92.   jul\or aug\or sep\or oct\or nov\or dec\fi}
  93. \tempcounta=1 \loop\ifnum\tempcounta<13
  94.   \xp\NewList\xp:\xp{\month\tempcounta}
  95.   \advance\tempcounta1 \repeat
  96. % Formatting the caboodle means:
  97. % -- loading the 'births' file
  98. % -- formatting each month separately by \OneMonth
  99. %   which is essentially a call to the text block \Month
  100. %
  101. \def\AllBirths{\LoadExternalFile:births
  102.   \tempcounta=1 \loop\ifnum\tempcounta<13
  103.   \OneMonth \advance\tempcounta1 \repeat}
  104. \def\OneMonth{\xp\Month\month\tempcounta\par
  105.   \TheList:{\month\tempcounta} \>}
  106. % Month is much like \Entity, just a bit different visually.
  107. %
  108. \DefineTextBlock:Month
  109.  whitebefore:{6pt plus 6pt minus 3pt} whiteafter:whitebefore
  110.  line:start rule:v={height 7pt width7pt depth0pt} Spaces:2
  111.       Style:italic title Spaces:2
  112.       fillup rule:v={height 7pt width7pt depth0pt} line:stop
  113.  Stop
  114. % When the external file is loaded, every birthday is processed
  115. % by \BirNam which splits it into #1 year #2 month #3 day and
  116. % #4 person's name. This is then written to the list for the
  117. % appropriate month.
  118. %
  119. \def\BirNam#1 #2 #3\unhskip #4\unhskip
  120.  {\tempcounta#2\relax
  121.   \AppendToList:{\month\tempcounta}={\JollyFellow #3 #4 (#1)\par}
  122.   }
  123. \DefineExternalItem:birthday file:births
  124.   expandafter BirNam title Stop
  125. \DefineHeading:JollyFellow title nomarks Stop
  126.  
  127. % Phooeew! Now we can get down to business!
  128.  
  129. \WriteExtern:yes
  130. \Start
  131. \LoadExternalFile:companies
  132.  
  133. \Entity Adam Aardvark
  134. \Address Page~1, English Language Dictionary
  135. \>
  136.  
  137. \Entity Barbara Beeton
  138. \At Tugbt
  139. \Note Editor in chief
  140. \>
  141.  
  142. \Entity Jane Doe
  143. \email doe@re.mi.sol
  144. \>
  145.  
  146. \Entity John Doe
  147. \phone +1 212 555 4141
  148. \>
  149.  
  150. \Entity Victor Eijkhout
  151. \Address Department of Computer Science, University of Tennessee
  152. \phone +1 615 974 8298
  153. \At Tugbt
  154. \Note merely associate editor
  155. \email eijkhout@cs.utk.edu
  156. \birthday 1959 11 29
  157. \>
  158.  
  159. \Entity Elvis Presley
  160. \birthday 1938(?) 01 08
  161. \>
  162.  
  163. \Entity Tugboat
  164. \TheList:Tugbt
  165. \>
  166.  
  167. \AllBirths
  168.  
  169. \Stop
  170.  
  171.